//Monday, December 07 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <sstream>
#include <algorithm>

using namespace std;

class FactoVisors
{
public:
	int getNum(vector <int> divisors, vector <int> multiples)
	{
		sort(divisors.begin(), divisors.end());
		sort(multiples.begin(), multiples.end());
// 		long long mmax1 = multiples[0];
// 		long long mmin = divisors[0];
// 		long long mmax2 = divisors[0];
// 		for(int i=0; i<multiples.size(); i++)
// 		{
// 			mmax1 = gcd(mmax1, multiples[i]);
// 		}
// 		for(int i=0; i<divisors.size(); i++)
// 		{
// 			mmax2 = gcd(mmax2, divisors[i]);
// 			mmin = mmin / mmax2 * divisors[i];
// 		}
		long long mmin = 1;
		long long mmax1 = (long long)sqrt(multiples[0])+1;
		for(int i=mmin; i<=mmax1; i++)
		{
			for(int j=0; j<multiples.size(); j++)
			{
				if(multiples[j] % i == 0)
				{
					check(divisors, multiples, i);
					check(divisors, multiples, multiples[j]/i);
				}
			}
		}
		return ret.size();
	}
	void check(vector <int> divisors, vector <int> multiples, int j)
	{
		for(int i=0; i<divisors.size(); i++)
			if(j % divisors[i] != 0)
				return;
		for(int i=0; i<multiples.size(); i++)
			if(multiples[i] % j != 0)
				return;
		ret.insert(j);
	}
	int gcd(int a, int b)
	{
		return b==0? a:gcd(b, a%b);
	}
	set<int> ret;

};
